#pragma once

#ifndef _fmbPtr
#define _fmbPtr

namespace fm {
  namespace base {


/// <summary>
///   Very simple implementation of auto pointer.
///   Pointer is passed in constructor and delete is called automatically during desctruction.
///   No possibiliy for copying or changing the pointer.
/// </summary>
/*template<typename T>
class SinglePtr {
  T* m_ptr;

  // prevent misuse
  SinglePtr(const SinglePtr &source);
  SinglePtr operator=(const SinglePtr &source);
public:

  inline SinglePtr(T* ptr) : m_ptr(ptr) {}
  inline ~SinglePtr() { if (m_ptr) delete m_ptr; }
  
  inline T* ptr() { return m_ptr; }
  inline T& operator*() const { return *m_ptr; }
  //inline const T& operator*() const { return *m_ptr; }

};*/

template<class T>
class SinglePtr {	

  // prevent misuse
  SinglePtr(const SinglePtr &source);
  SinglePtr operator=(const SinglePtr &source);
public:

	explicit SinglePtr(T *ptr = 0) : m_ptr(ptr) { }
	~SinglePtr() { delete m_ptr; }
	T& operator*() const { return (*ptr()); }
	T *operator->() const { return (ptr()); }
	T *ptr() const { return (m_ptr); }

private:
	T *m_ptr;
};

  // end of namespace fm::base
  }
// end of namespace fm
}


#endif
